<template>
  <van-cell
    :to="{
    name:'article',
    params:{
      articleId:artItem.art_id
    }
  }"
    class="article-item"
  >
    <div
      slot="title"
      class="title van-multi-ellipsis--l2"
    >
      {{artItem.title}}
    </div>
    <div slot="label">
      <div
        v-if="artItem.cover.type === 3"
        class="cover-wrap"
      >
        <van-image
          v-for="(item,index) in artItem.cover.images"
          :key="index"
          fit="cover"
          class="center-img"
          :src="item"
        />
      </div>
      <div class="label-info-wrap">
        <span>{{artItem.aut_name}}</span>
        <span>{{artItem.comm_count}} 评论</span>
        <span>{{artItem.pubdate | relativeTime}}</span>
      </div>
    </div>
    <van-image
      v-if="artItem.cover.type === 1"
      slot="default"
      fit="cover"
      class="right-img"
      :src="artItem.cover.images[0]"
    />
  </van-cell>
</template>

<script>
export default {
  name: 'ArticleItem',
  props: {
    artItem: {
      type: Object,
      required: true
    }
  }
}
</script>

<style scoped lang="less">
.article-item {
  padding: 0;
  .title {
    font-size: 32px;
    color: #3a3a3a;
  }
  .van-cell__title {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .van-cell__value {
    flex: unset;
    width: 232px;
    height: 146px;
    .right-img {
      width: 100%;
      height: 100%;
    }
  }
  .label-info-wrap span {
    font-size: 22px;
    color: #b4b4b4;
    margin-right: 25px;
  }
  .cover-wrap {
    display: flex;
    padding: 30px 0;
    justify-content: center;
    align-items: center;
    .center-img {
      width: 232px;
      height: 146px;
      &:not(:last-child) {
        margin-right: 5px;
      }
    }
  }
}
</style>
